package com.jhhc.WaterQuality.Calculate.Forecast.util;

import java.text.DecimalFormat;
import java.util.Random;

public class Estimate {

    public static String dataEstimate(String value,String dataType){
        DecimalFormat decimalFormat = new DecimalFormat("#.##");
        double v = Double.parseDouble(value);
        double lowerBound = 0; // Lower bound of the random number
        double upperBound = 0;
        double result =0;
        String formattedValue;
        Random random = new Random();
        switch (dataType){
            case "TN（总氮）":
                lowerBound = 0;
                upperBound = 2;
                formattedValue = decimalFormat.format((lowerBound + (upperBound - lowerBound) * random.nextDouble()));
                result = Double.parseDouble(formattedValue);
                if (result <= 0.2) {
                    return "I类";
                } else if (result <= 0.5) {
                    return "II类";
                } else if (result <=1) {
                    return "III类";
                } else if (result <= 1.5) {
                    return "IV类";
                } else if (result <= 2.0) {
                    return "V类";
                }
            case "氨氮":
                lowerBound = 0;
                upperBound = 2;
                formattedValue = decimalFormat.format((lowerBound + (upperBound - lowerBound) * random.nextDouble()));
                result = Double.parseDouble(formattedValue);
                if (result <= 0.15) {
                    return "I类";
                } else if (result <= 0.5) {
                    return "II类";
                } else if (result <=1) {
                    return "III类";
                } else if (result <= 1.5) {
                    return "IV类";
                } else if (result <= 2.0) {
                    return "V类";
                }
            case "COD（化学需氧量）":
                lowerBound = 0;
                upperBound = 40;
                formattedValue=   decimalFormat.format((lowerBound + (upperBound - lowerBound) * random.nextDouble()));
                result = Double.parseDouble(formattedValue);
                if (result <= 15) {
                    return "II类";
                } else if (result <= 15) {
                    return "II类";
                } else if (result <= 20) {
                    return "III类";
                } else if (result <= 30) {
                    return "IV类";
                } else if (result<=40){
                    return "V类";
                }
            case "BOD（生化需氧量）":
                lowerBound = 0;
                upperBound = 10;
                formattedValue=   decimalFormat.format((lowerBound + (upperBound - lowerBound) * random.nextDouble()));
                result = Double.parseDouble(formattedValue);
                // Adjust the interval calculation for Type B data
                if (result <= 3) {
                    return "I类";
                } else if (result <= 3) {
                    return "II类";
                } else if (result <= 4) {
                    return "III类";
                } else if (result <= 6) {
                    return "IV类";
                } else  if (result <= 10){
                    return "V类";
                }
            case "总磷":
                lowerBound = 0;
                upperBound = 0.3;
                formattedValue=   decimalFormat.format((lowerBound + (upperBound - lowerBound) * random.nextDouble()));
                result = Double.parseDouble(formattedValue);
                // Adjust the interval calculation for Type B data
                if (result <= 0.02) {
                    return "I类";
                } else if (result <= 0.1) {
                    return "II类";
                } else if (result <= 0.2) {
                    return "III类";
                } else if (result <=0.3) {
                    return "IV类";
                } else if (result<=0.4){
                    return "V类";
                }
            default:
                return null;
        }

    }


}
